/* GUI CONVERTED from reschiq.p (converter v1.75) Fri Jun 22 15:25:45 2001 */
/* reschiq.p - REPETITIVE                                                     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.13 $                                                           */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.3               LAST MODIFIED: 10/31/94   BY: WUG *GN77*       */
/* REVISION: 7.3    LAST MODIFIED: 07/09/96 BY: *G1XX* Julie Milligan         */
/* REVISION: 7.3    LAST MODIFIED: 07/30/96 BY: *G2B3* Julie Milligan         */
/* REVISION: 8.6               LAST MODIFIED: 10/11/97   BY: bvm *K0SG*       */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.0      LAST MODIFIED: 10/14/98   BY: *J32B* Felcy D'Souza      */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.13 $    BY: Hualin Zhong   DATE: 06/13/01 ECO: *N0ZF*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* REPETITIVE SCHEDULE INQUIRY                                                */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reschiq_p_2 "Qty Open"
/* MaxLen: Comment: */

&SCOPED-DEFINE reschiq_p_4 "Scheduled"
/* MaxLen: Comment: */

&SCOPED-DEFINE reschiq_p_10 "Completed + Scrap"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable site like rps_site.
define variable prline like rps_line.
define variable due like rps_due_date.
define variable part like rps_part.
define variable open_ref like rps_qty_req column-label {&reschiq_p_2}.
define variable wday as character format "x(9)".
define variable wdays like wday extent 7.
define variable i as integer.
define variable rps_start like rps_due_date.
define variable duedate as date.

assign
   wdays[1] = getTermLabel("SUNDAY",9)
   wdays[2] = getTermLabel("MONDAY",9)
   wdays[3] = getTermLabel("TUESDAY",9)
   wdays[4] = getTermLabel("WEDNESDAY",9)
   wdays[5] = getTermLabel("THURSDAY",9)
   wdays[6] = getTermLabel("FRIDAY",9)
   wdays[7] = getTermLabel("SATURDAY",9)
   part     = global_part
   site     = global_site.

find first lnd_det
where lnd_site = site and lnd_part = part no-lock no-error.

if available lnd_det then
   prline = lnd_line.
find first rpc_ctrl no-lock no-error.

due = today.
if weekday(due) = 1 then
   due = due + 1.
else
   due = due + 2 - weekday(due).


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   part
   pt_desc1 no-label format "x(16)"
   site
   prline
   due
with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}

repeat:

   if c-application-mode <> 'web' then
      update
         part
         site
         prline
         due
      with frame a editing:

      if frame-field = "part" then do:
         {mfnp.i rps_mstr part rps_part part rps_part rps_part}

         if recno <> ? then do:

            display
               rps_part @ part
            with frame a.

            find pt_mstr no-lock where pt_part = rps_part no-error.

            if available pt_mstr then
               display
                  pt_desc1 with frame a.
            else
               display
                  " " @ pt_desc1 with frame a.
            recno = ?.
         end.
      end.
      else
      if frame-field = "site" then do:
         {mfnp05.i
            rps_mstr rps_part "rps_part = input part" rps_site "input site"}

         if recno <> ? then do:

            display
               rps_site @ site
               rps_line @ prline
            with frame a.

            recno = ?.
         end.
      end.

      else
      if frame-field = "prline" then do:
         {mfnp05.i
            rps_mstr rps_part "rps_site = input site and rps_part = input part"
            rps_line "input prline"}

         if recno <> ? then
            display
               rps_line @ prline with frame a.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.
   end.

   {wbrp06.i &command = update &fields = "  part site prline due" &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      find pt_mstr where pt_part = part no-lock no-error.

      if not available pt_mstr then do:

         /* ITEM NUMBER DOES NOT EXIST */
         {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
         if c-application-mode = 'web' then return.
         undo , retry.
      end.

      display
         pt_part @ part
         pt_desc1 with frame a.
      find si_mstr no-lock where si_site = site no-error.

      if not available si_mstr then do with frame a:

         /* SITE DOES NOT EXIST */
         {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}

         if c-application-mode = 'web' then
            return.
         else
            next-prompt site.
         undo , retry.
      end.

      find first ln_mstr no-lock where ln_line = prline no-error.

      if not available ln_mstr and prline > "" then do:

         /* PRODUCTION LINE DOES NOT EXIST */
         {pxmsg.i &MSGNUM=8524 &ERRORLEVEL=3}

         if c-application-mode = 'web' then
            return.
         else
            next-prompt prline with frame a.
         undo , retry.
      end.

      find first ln_mstr no-lock
      where ln_line = prline
        and ln_site = site no-error.

      if not available ln_mstr then do:
         find first ln_mstr no-lock where ln_site = site no-error.

         if available ln_mstr then do:

            /* SITE PRODUCTION LINE DOES NOT EXIST */
            {pxmsg.i &MSGNUM=8526 &ERRORLEVEL=3}

            if c-application-mode = 'web' then
               return.
            else
               next-prompt prline with frame a.
            undo, retry.
         end.
      end.

      find first rps_mstr
      where rps_part = part and rps_site = site and rps_line = prline
      no-lock no-error.

      if not available rps_mstr then do:

         /* SCHEDULE DOES NOT EXIST */
         {pxmsg.i &MSGNUM=7156 &ERRORLEVEL=3}
         if c-application-mode = 'web' then
            return.
         undo , retry.
      end.

      hide frame b.

   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   duedate = due.
   if duedate = ? then
      duedate = low_date.

   for each rps_mstr no-lock
   where rps_part = part
     and rps_site = site
     and rps_line = prline
     and rps_due_date >= duedate
   with frame b width 80 no-attr-space:
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

      open_ref = rps_qty_req - rps_qty_comp.

      /* COMMENTED OUT AS WEEKDAYS ARE NOT DISPLAYED PROPERLY IN CHINESE */
      /* LANGUAGE WHEN RIGHT JUSTIFIED WITH FILL CHARACTERS IN THE       */
      /* BEGINING FOR THE DISPLAY PURPOSE.                               */

      display
         wdays[weekday(rps_due_date) ] @ wday no-label
         rps_rel_date
         rps_due_date
         rps_qty_req column-label {&reschiq_p_4}
         rps_qty_comp
         column-label {&reschiq_p_10}
         open_ref
      with frame b STREAM-IO /*GUI*/ .
   end.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


   /* LIST COMPLETE */
   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}
   assign
      global_part = part
      global_site = site.
end.

{wbrp04.i &frame-spec = a}
